<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('费用报销')" />
	<th:block th:include="include :: businessCSS" />
</head>
<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	<form class="layui-form head-form">
	    <div class="north">
       		<th:block th:include="include :: business_btn" />
	        <th:block th:include="include :: business_tpl('top')" />
    	</div>
	    <div class="mid-content">
	        <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
	    </div>
	    <th:block th:include="include :: pageFooter" /> 
        </form>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: businessTableBtn" />
<!-- 费用信息 -->
<script id="change1" type="text/template">
<table class="layui-hide" id="dhtable_c" lay-filter="ftable_c"></table>
</script>
<th:block th:include="include :: inlineJS" />
<script type="text/javascript">
var $,layer,form,table,laydate,element;//定义layui模块
eachFields();//明细表格中的字段遍历
layui.use(['laydate', 'table','form','layer','jquery','util','element'], function () {
 	$ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,laydate = layui.laydate,util = layui.util,element=layui.element;
 	beforeInit();//表单初始化之前的动作集合
 	layui.element.render();
 	$.get("/business/expenseaccount/listbynid?nid="+nid,function(data){
		$.each(data.data,function(k,v){
			dataStr.push(v);
		});
		initTable();//初始化表格
	});
	//头部event事件
	table.on('toolbar(ftable)', function(obj){
		var checkStatus = table.checkStatus('dhtable');
	    switch(obj.event){
	    	case 'addBtn':
	    		if(listData.length > 0){
	    			if(listData[listData.length - 1]['iid']){
	    				gridColumns.gridNewLine.iid = Number(listData[listData.length - 1]['iid']) + 1;//行号自增1
	    			}else{
	    				gridColumns.gridNewLine.iid = 1;
	    			}
	    		}else{
	    			gridColumns.gridNewLine.iid = 1;
	    		}
	    		listData.push(gridColumns.gridNewLine);
	        	table.reload('dhtable', {data : listData});
	      		form.render();
	    	break;
	    	case 'deleteBatch':
	    		tableDeleteBatch('dhtable', listData, checkStatus);
	    	break;
	    	case 'fieldSet':
	    		filedSet(moduleTable+'_EditPage202109');
         	break;
			case 'tableFull'://表格展开
				$('.north .layui-form').hide();
				table.reload('dhtable',{
					defaultToolbar: [{title:'收缩',layEvent:'tableShrink',icon:'layui-icon-screen-restore'}],
					height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
				});
			break;
			case 'tableShrink'://表格收缩
				$('.north .layui-form').show();
				table.reload('dhtable',{
					defaultToolbar: [{title:'展开',layEvent:'tableFull',icon:'layui-icon-screen-full'}],
					height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
				});
			break;
	    	case 'importBtn':
	    		$.tablelist.importExcel('dhtable',importFields, table.cache.dhtable, moduleTable, decimalObj);
         	break;
	    	case 'change':
	    		layer.open({
            		type: 1,
            		area: [($(window).width() - 400)+'px', ($(window).height() - 200)+'px'],
            		fix: false,//不固定
            		offset: '10%',//距离顶部
            		maxmin: true,//最大最小化
            		shade: 0.3,//遮罩
            		title: '费用信息',
            		content: $('#change1').html(),
            		btn: ['保存', '取消'],
            		shadeClose: true,// 弹层外区域关闭
            		success: function(layero, index){
            			var layCols=[
        		   			{type: "numbers",fixed: "left",width: 40},
        		   			{width: 100,sort: true,field: "iid",title: "<font class='f_red'>*</font>行号",align: "center"},
        		   			{width: 200,sort: true,field: "fSumje",title: "承担金额",align: "center",edit:true},
        		   			{width: 200,sort: true,field: "vFyXm",title: "费用项目编码",align: "center"},
        		   			{width: 200,sort: true,field: "vFyXmName",title: "费用项目",align: "center"},
        		   			{width: 200,sort: true,field: "vFyMx",title: "费用明细编码",align: "center"},
        		   			{width: 200,sort: true,field: "vFyMxName",title: "费用明细",align: "center",templet:'#buttontext_vFyMxName'},
        		   			{width: 200,sort: true,field: "vPzHm",title: "凭证号码",align: "center",edit:true},
        		   			{width: 200,sort: true,field: "vZy",title: "摘要",align: "center",edit:true},
        		   			{width: 200,sort: true,field: "cUser",title: "承担员工号",align: "center"},
        		   			{width: 200,sort: true,field: "cUserName",title: "承担员",align: "center",templet:'#buttontext_cUserName'},
        		   			{width: 200,sort: true,field: "cDept",title: "承担员部门路径",align: "center"},
        		   			{width: 200,sort: true,field: "cDeptName",title: "承担员部门",align: "center"}
        		   		];
            			$.tablelist.init({
            				elem: '#dhtable_c'
            				,data: table.cache.dhtable
            				,page: false
            				,even: true
            				,limit: 1000
            		   		,cols: [layCols
            				]
            				,height:'full-300'
           					,done:function(res, curr, count){
           						$.each(layCols,function(i,v){
           							if(!v.edit)$("[lay-id='dhtable_c'] .layui-table-main [data-field='"+v.field+"']").css('background-color','#F2F2F2');
           						});
           					}
            			});
            		},
            		yes: function(index, layero){
            			var pd=[];
            			$.each(table.cache.dhtable_c,function(i,v){
            				pd.push({"guid":v.guid,"fSumje":v.fSumje,"iid":v.iid,"vFyMx":v.vFyMx,"vFyMxName":v.vFyMxName,"vFyXm":v.vFyXm,"vFyXmName":v.vFyXmName,"vPzHm":v.vPzHm,"vZy":v.vZy,"cUser":v.cUser,"cUserName":v.cUserName,"cDept":v.cDept,"cDeptName":v.cDeptName});
            			})
            			var postData = {'infoItems':JSON.stringify(pd)};//转化为json字符串格式
            		    $.operate.post(moduleUrl+'/xgxxpost', postData, function(res){
            		        if(res.code == 0){
            		        	goUrl(moduleUrl+'/edit?nid='+nid);
            		        }
            		    });
            		}
            	});
   			break;
	    };
	});
	monitorSort();//监听排序——重载赋值渲染
	toolEvent('ftable');//行event事件监听
})
</script>
</body>
</html>